package javaee14.Business;

import javaee14.DAO.DrinkDAO;
import javaee14.DAO.InDAO;
import javaee14.DAO.OutDAO;
import javaee14.DAO.UsersDAO;
import javaee14.Model.Drink;
import javaee14.Model.In;
import javaee14.Model.Out;
import javaee14.Model.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SaleService {
    DrinkDAO drinkDAO;
    InDAO inDAO;
    OutDAO outDAO;
    UsersDAO usersDAO;

    @Autowired
    public void setDrinkDAO(DrinkDAO drinkDAO) { this.drinkDAO = drinkDAO;}
    @Autowired
    public void setInDAO(InDAO inDAO) { this.inDAO = inDAO; }
    @Autowired
    public void setOutDAO(OutDAO outDAO) { this.outDAO = outDAO; }
    @Autowired
    public void setUsersDAO(UsersDAO usersDAO) { this.usersDAO = usersDAO; }
    public void insert(Drink drink){ drinkDAO.insertDrink(drink); }

    @Transactional
    public void Drinkinsrt(Drink b){ drinkDAO.insertDrink(b);}
    public void Drinkdelete(Drink b){drinkDAO.deleteDrink(b);}
    public void Drinkmodify(Drink b){drinkDAO.modifyDrink(b);}
    public Drink Drinkquery(Drink b){ return drinkDAO.queryDrink(b);}
    public Drink Drinkquery1(Drink b){ return drinkDAO.queryDrink(b);}
    public List<Drink> Drinkqueryall(){ System.out.println(drinkDAO.queryAll());return drinkDAO.queryAll(); }

    public void Ininsrt(In in){inDAO.insertIn(in);}
    public void Indelete(In in){inDAO.deleteIn(in);}
    public void Inmodify(In in){inDAO.modifyIn(in);}
    public In Inquery(In in){System.out.println(inDAO.queryIn(in));return inDAO.queryIn(in);}
    public List<In> Inqueryall(){ System.out.println(inDAO.queryAll());return inDAO.queryAll();}

    public void Outinsrt(Out out){outDAO.insertOut(out);}
    public void Outdelete(Out out){outDAO.deleteOut(out);}
    public void Outmodify(Out out){outDAO.modifyOut(out);}
    public Out Outquery(Out out){System.out.println(outDAO.queryOut(out));return outDAO.queryOut(out);}
    public List<Out> Outqueryall(){return outDAO.queryAll();}

    public void Usersinsrt(Users users){usersDAO.insertUsers(users);}
    public void Usersdelete(Users users){usersDAO.deleteUsers(users);}
    public void Usersmodify(Users users){usersDAO.modifyUsers(users);}
    public void Usersquery(Users users){usersDAO.queryUsers(users);}
    public List<Users> Usersqueryall(){return usersDAO.queryAll();}

}
